﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Pigmalion.BusinessEntities; 

namespace Pigmalion.DataAccess
{
    public partial class ClienteRepository:MasterDAABRepository,IClienteRepository
    {
        public ClienteRepository()
        { 
        
        }
        public List<Cliente> GetAllFromCliente()
        {
            var clientes = PigmalionDatabase.ExecuteSprocAccessor<Cliente>("GetAllFromCliente");

            return clientes.ToList();
        }

        public List<Cliente> GetFromClienteByRazonSocial(string criterio)
        {
            var clientes = PigmalionDatabase.ExecuteSprocAccessor<Cliente>("GetFromClienteByRazonSocial",criterio);

            return clientes.ToList();
        }

        public List<Cliente> GetOneFromClienteByRucDni(string criterio)
        {
            var clientes = PigmalionDatabase.ExecuteSprocAccessor<Cliente>("GetFromClienteByRucDni", criterio);

            return clientes.ToList();
        }

        Cliente IClienteRepository.GetOneFromClienteByRucDni(string criterio)
        {
            var cliente = PigmalionDatabase.ExecuteSprocAccessor<Cliente>("GetFromClienteByRucDni", criterio);

            return cliente.FirstOrDefault();
        }

        public Cliente GetFromClienteById(int id)
        {
            var cliente = PigmalionDatabase.ExecuteSprocAccessor<Cliente>("GetFromClienteById", id);

            return cliente.First();
        }


        public List<Cliente> GetFromClienteByRucDni(string criterio)
        {
            throw new NotImplementedException();
        }

    }
}
